<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
   var firstUniqChar = function (s) {
      let map = new Map();
      for (let v of s) {
        if (map.has(v)) {
          console.log(v);
          // console.log(map.get(v) + 1);
          map.set(v, map.get(v) + 1)
        } else {
          map.set(v, 1);
        }
      }

      console.log(map);
      map.forEach((key,value) => {
        if(value == 1) {
          return key;
        }
      })
      return ' '
    };
    console.log(firstUniqChar("abaccdeff"));
  </script>
</body>
</html>